package com.heima.config;

import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
public class MqConfig {
    private final RabbitTemplate rabbitTemplate;
    @PostConstruct
    public void init(){
        rabbitTemplate.setReturnsCallback(returns -> {
            System.out.println("消息发送失败：" + returns.getMessage());
            System.out.println("失败原因：" + returns.getReplyText());
            System.out.println("消息：" + returns.getMessage());
            System.out.println("交换机：" + returns.getExchange());
            System.out.println("路由键：" + returns.getRoutingKey());
        });
    }
}
